Skip to content

fix(ramps-controller): refresh countries catalog on app startup#9261

Open
amitabh94 wants to merge 6 commits into
mainfrom
fix/tram-3682-countries-catalog-refresh-on-start
Open

fix(ramps-controller): refresh countries catalog on app startup#9261
amitabh94 wants to merge 6 commits into
mainfrom
fix/tram-3682-countries-catalog-refresh-on-start

Conversation

@amitabh94

@amitabh94 amitabh94 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Explanation

Stale persisted countries catalog data caused preset amounts (e.g. $100 / $250 / $500) to stay wrong after app restarts until the user changed region, even when the API had updated values.

This change is controller-only in @metamask/ramps-controller — no MetaMask Mobile or portfolio changes.

  • Mark the countries catalog as non-persisted (persist: false) so restarts do not reuse stale catalog data.
  • On init(), always refetch countries via getCountries() (including when userRegion is already set).
  • After each successful getCountries(), re-sync userRegion preset amounts from the fresh catalog via #syncUserRegionFromCountriesCatalog.
  • Tests cover init refetch, userRegion re-sync, and persistence metadata.

Consumers need a new @metamask/ramps-controller release; mobile can pick it up via the usual Core dependency bump.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Made with Cursor

@amitabh94 amitabh94 requested review from a team as code owners June 25, 2026 04:30
amitabh94 and others added 5 commits June 25, 2026 12:42
Stop persisting the countries catalog and force-refetch via init() so
preset amounts stay in sync after app restarts.

TRAM-3682

Co-authored-by: Cursor <cursoragent@cursor.com>
TRAM-3682

Co-authored-by: Cursor <cursoragent@cursor.com>
@wenfix wenfix force-pushed the fix/tram-3682-countries-catalog-refresh-on-start branch from dae992f to 82c35e8 Compare June 25, 2026 11:56

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 82c35e8. Configure here.

Comment thread packages/ramps-controller/src/RampsController.ts

@saustrie-consensys saustrie-consensys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left an important question before I can approve

if (forceRefresh || !hasCountries) {
await this.getCountries(options);
}
await this.getCountries({ ...options, forceRefresh: true });

@saustrie-consensys saustrie-consensys Jun 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amitabh94 @wenfix Why not simply use forceRefresh? We created that option for a reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants